package com.yc.thread.interrupte;

import java.util.concurrent.LinkedBlockingQueue;

public class InterruptBlockingQueue {

    public static void main(String[] args) {
        InterruptBlockingQueue t = new InterruptBlockingQueue();
        t.m1();
    }

    public void m1() {
        Thread t = new Thread(() -> {
            System.out.println("------t start");
            LinkedBlockingQueue queue = new LinkedBlockingQueue<String>();
            try {
                queue.take();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("------t end");
        });
        t.start();

        try {
            Thread.sleep(1000);//暂停1秒，确保线程被阻塞在queue.take();
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }

        t.interrupt();//主线程发出中断信号

    }
}
